package cn.yangmin.gateway.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author diandian
 * @date 2021-12-10 11:27
 */
@Component
@Slf4j
public class FooFilter implements GlobalFilter , Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("我是foo过滤器");
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        // 可以指明执行顺序   数字越小 执行越靠前
        return 1;
    }
}
